package converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;

@FacesConverter("LowerCaseConverter")
public class LowerCaseConverter implements Converter{
	
	public Object getAsObject (FacesContext fc, UIComponent c, String valorTela) throws ConverterException {
			if (valorTela == null ||
				 valorTela.trim().equals("")) {
			     return null;
			} else {
			        return valorTela.toLowerCase();
			}
	}
	
	public String getAsString (FacesContext arg0, UIComponent arg1, Object valor) throws ConverterException {
		if (valor == null || 
			valor.toString().trim().equals("")) {
			return "";
		} else {
			return valor.toString();
		}
	}
}